<?php
include_once("config/config.php");
$adminSession = $_COOKIE["username"] ? $_COOKIE["username"] : '';
if (empty($adminSession)) {
  ShowMsg("请先登录", 'login.php');
  exit;
}

$adminAll = findAll("select * from admin");
$adminid = '';
foreach($adminAll as $item) {
  $idsaltMD5 = md5($item['id'] . $item['salt']);
  if ($adminSession == $idsaltMD5) {
    $adminid = $item['id'];
    break;
  }
}
$resAdmin = findOne("select * from admin where id = '$adminid'");
if (!$resAdmin) {
  setcookie('username', null);
  ShowMsg("非法登录", 'login.php');
  exit;
}

?>

<div class="navbar">
  <div class="navbar-inner">
    <ul class="nav pull-right">
      <li>
        <a href="#" role="button">
          <i class="icon-user"></i><?php echo $resAdmin['username']; ?>
        </a>
      </li>
      <li>
        <a href="logout.php" class="hidden-phone visible-tablet visible-desktop" role="button">Logout</a>
      </li>
    </ul>
    <a class="brand" href="index.php"><span class="second">Admin</span></a>
  </div>
</div>